<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
	
    <head th:include="/common/header :: source"></head>
	<body>
	<div th:include="/common/header :: header"></div>
	
    <!-- 底部表格 -->
	<div class="panel panel-default">
		<div class="panel-body" style="width: 100%;height: 750px;">
			<table class="table table-striped table-bordered">
				<caption>商城用户列表</caption>
				<thead>
					<tr>
						<th>序号</th>
						<th>名称</th>
						<th>图片</th>
						<th>sku名称</th>
						<th>原价</th>
						<th>售卖价</th>
						<th>活动名称</th>
						<th>活动优惠</th>
						<th>创建时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody >
					<tr th:each="products : ${products}">
						<th th:text="${products.id}" th:id="'products_'+${products.id}"></th>
						<th th:text="${products.name}"></th>
						<th th:text="${products.img}"></th>
						<th th:text="${products.sku}"></th>
						<th th:text="${products.relPrice}">￥</th>
						<th th:text="${products.salPrice}">￥</th>
						<th th:text="${products.discountName}"></th>
						<th th:text="${products.discountPrice}">￥</th>
						<th style="width:300px;" th:text="${products.createTime}"></th>
						<th style="width:130px;">
							<button type="button" class="btn btn-primary">查看</button>
							<button type="button" th:onclick="'javascript:deleteProduct(\''+${products.id}+'\');'" class="btn btn-danger">删除</button>					
						</th>
					</tr>
				</tbody>
		    </table>
	    </div>
	</div>
	</body>
	<script type="text/javascript">
	/**
	 * 登录首界面
	 */
	$(function(){
		
	})
	function deleteProduct(id){
		layer.confirm('确定删除？', {
			  btn: ['取消','确定']
			}, function(){
			  layer.msg('请继续操作', {icon: 6});
			}, function(){
				$.ajax({  
		            type: 'post',  
		            dataType: 'json',  
		            url: basePath + '/admin/product/delete',  
		            data: {
		            	productId:id
		            },  
		            cache: false,  
		            async: true,  
		            success: function (data) {
		            	layer.msg(data.msg, {icon: 6});
		            	if(data.code=="200"){
		            		$("#products_"+id).closest("tr").children("th").remove();
		            	}
		            }  
		        });
			});
	}
	</script>
</html>
